package cn.com.jslh.boarpro.main.model;

import android.content.Context;

import com.blankj.utilcode.util.SPUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;
import java.util.Map;

import cn.com.jslh.boarpro.base.BaseApplication;
import cn.com.jslh.boarpro.main.contract.SearchContract;
import cn.com.jslh.boarpro.util.WebService;

/**
 * Created by Administrator on 2017/11/10.
 */

public class SearchModelImpl implements SearchContract.Model {
    @Override
    public void getSearchInitInfo(Context context, String searchType, WebService.NetSuccessListener netSuccessListener) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("userID", SPUtils.getInstance().getString(BaseApplication.FUSERID));
            jsonObject.put("lineID", SPUtils.getInstance().getString(BaseApplication.FLINEID));
            jsonObject.put("searchType", searchType);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        new WebService.Builder(context, "exportCondOrResult", "WSSearchConditionFacade")
                .addProperty("jsonString",jsonObject.toString())
                .addProperty("returnType","condition")
                .showDialog(false)
                .success(netSuccessListener)
                .post();
    }

    @Override
    public void subData(Context context, JSONObject jsonObject, WebService.NetSuccessListener netSuccessListener) {
        new WebService.Builder(context, "exportCondOrResult", "WSSearchConditionFacade")
                .addProperty("jsonString",jsonObject.toString())
                .addProperty("returnType","result")
                .showDialog(false)
                .success(netSuccessListener)
                .post();
    }

}
